const videoArr = [
  {
    video_id: '11011',
    video_src: 'https://v.bestqd.cn/d59c29ac3aea490d99ddf94f18d74b83/013a947b8a434744865f9d36c13f4010-77944da7b610d4fda2d8a31b146936b8-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11012',
    video_src: 'https://v.bestqd.cn/5e7c6b244ef546b89facc489d656191a/ee6956373cbb4cc98c083bc3e11f43ef-d8a5113347f68ca40b65e572ce66f1c1-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11021',
    video_src: 'https://v.bestqd.cn/ad47f208a1274d668d631116930eed63/37f216ec5d814bca85ce9b6eb76f6f7e-95deb4d856fa0b079172114a577c90a6-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11022',
    video_src: 'https://v.bestqd.cn/a0a74d4f81fa4af3afff6f9f7bd72e31/892279f7f54a45d38482bb9d7375d96a-7f7f9109860bd9e8a02461305ca493b4-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11023',
    video_src: 'https://v.bestqd.cn/9b4d35ae11aa4897ba9a26be33b5daf0/35f5879ec52a45bdbe6014be6a28154e-7309f3c074029193ee3a33b96598cabc-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11024',
    video_src: 'https://v.bestqd.cn/fcc3f4b8d97f44459f552fa7395ab7f8/4bcdab97aad8438ebd818665edf3341f-b2368e30c9a794580a559d6856f414f5-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11031',
    video_src: 'https://v.bestqd.cn/a15abc58c736401bac6717384bebde83/4972650f8f974760a75194393ca434fb-901b885309bb2551628a5a0edd52d08d-od-S00000001-100000.m3u8'
  },
  {
    video_id: '11032',
    video_src: 'https://v.bestqd.cn/50a3dff66912432e96514af5395b6c04/9535186db0104329be905a690190352e-82e466e799fb59650ea30810fcf8dc78-od-S00000001-100000.m3u8'
  }
]

module.exports = function (videoid) {
  let video_index = 0
  let video_src = ''
  let videoinfo = videoArr.find((item, index) => {
    video_index = index
    return item.video_id == videoid
  })

  video_src = videoinfo ? videoinfo.video_src : video_src

  const video_list = 
    [
      {
        chapter: "准备", 
        list:[
          {title: '演示：公众号支付', url: '/videos/11011'},
          {title: '准备项目', url: '/videos/11012'}
        ]
      },
      {
        chapter: '授权', 
        list:[
          {
            title: '配置网页授权目录与支付授权目录', 
            url: '/videos/11021'
          }, 
          {
            title: 'OpenID 与 UnionID', 
            url: '/videos/11022'
          },
          {
            title: '微信网页授权：获取 code 值', 
            url: '/videos/11023'
          },
          {
            title: '微信网页授权：获取 access_token，得到用户的 openid', 
            url: '/videos/11024'
          }
        ]
      },
      {
        chapter: '公众号支付', 
        list:[
          {
            title: '公众号支付：统一下单', 
            url: '/videos/11031'
          }, 
          {
            title: 'JSAPI：准备参数与支付', 
            url: '/videos/11032'
          }
        ]
      }
    ]

  let video_arr = Array.prototype.concat.apply([], video_list.map(item => item.list))
  let prev_url = video_index != 0 ? video_arr[video_index-1].url : ''
  let next_url = video_index < video_arr.length - 1 ? video_arr[video_index+1].url : ''
  let current_url = video_arr[video_index].url

  return {
    video_list,
    video_src,
    prev_url,
    next_url,
    current_url
  }
}

